package cn.xy

import java.io.FileOutputStream
import java.util.{Calendar, Date}

import org.apache.poi.xssf.usermodel.XSSFWorkbook

/**
  * Created by xiaoyuan on 2017/11/16.
  */
object Poi {
  def main(args: Array[String]): Unit = {
    val wb = new XSSFWorkbook
    val fileOut = new FileOutputStream("d:/workbook.xlsx")
    try {
      val sheet = wb.createSheet("new sheet")
      val row = sheet.createRow(2.toShort)
      row.createCell(0).setCellValue(1.1)
      row.createCell(1).setCellValue(new Date)
      row.createCell(2).setCellValue(Calendar.getInstance)
      row.createCell(3).setCellValue("a string")
      row.createCell(4).setCellValue(true)
      wb.write(fileOut)
    }catch {
      case e:Exception=>e.printStackTrace();
    } finally {
      if(fileOut!=null){
        fileOut.flush()
        fileOut.close
      }

      if(wb!=null){
        wb.close
      }
    }


  }
}
